package com.fjw.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

public enum DBUtils {
    DB;
    public  QueryRunner qr;

    DBUtils(){
        //加载数据库配置文件
        try {
            InputStream is = DBUtils.class.getResourceAsStream("db.properties");
            Properties pro  = new Properties();
            pro.load(is);
            DataSource ds = DruidDataSourceFactory.createDataSource(pro);

            qr = new QueryRunner(ds);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


    }


}
